import request from "@/utils/request";


/**
 * 添加运营
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveAdmin(data){
  return request({
    url: `/admin/saveAdmin`,
    method: 'post',
    data,
    handleError: true,
  })
}

/**
 * 编辑运营
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function editAdmin(data){
  return request({
    url: `/admin/editAdmin/${data.id}`,
    method: 'post',
    data,
    handleError: true,
  })
}


/**
 * 获取运营列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getAdminList(params = {}){
  return request({
    url: `/admin/getAdminList`,
    method: 'get',
    params,
  })
}

/**
 * 获取所有的运营
 * @returns {Promise | Promise<unknown>}
 */
export function getAllAdmin(){
  return request({
    url: '/admin/getAllAdmin',
    method: 'get',
  })
}

/**
 * 获取所有用户店铺的权限
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getAllAuthAccount(params = {}){
  return request({
    url: '/admin/getAllAuthAccount',
    method: 'get',
    params
  })
}

/**
 * 获取登录的链接
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function getAdminLoginWithKey(id){
  return request({
    url: `/admin/getAdminLoginWithKey/${id}`,
    method: 'get'
  })
}
